//
//  HouseLoanCalculatePage.m
//  YiJuZhangShou2.0
//
//  Created by URANUS on 16/3/28.
//  Copyright © 2016年 Mr.X. All rights reserved.
//

#import "HouseLoanCalculateViewController.h"
#import "HouseLoanCalculateView.h"
#import "Masonry.h"
#import "UIAlertControllerUtil.h"
#import "DetailCaculateNavView.h"
#import "CalculateLoanViewController.h"

@interface HouseLoanCalculateViewController()
@property (nonatomic, strong) HouseLoanCalculateView *houseLoanCalculateView;
@property (nonatomic, strong) DetailCaculateNavView  *MyNavView;
@end

@implementation HouseLoanCalculateViewController
- (void)loadView{
    UIView *backView=[[UIView alloc] initWithFrame:_caculateRect];
    self.view=backView;
}

#pragma mark - Life Cycle
- (void)viewDidLoad{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithRed:0.8784 green:0.8941 blue:0.9412 alpha:1.0];
    [self loadHouseLoanCalculateViewController];
    __weak UIViewController *weakSelf = self;
    self.MyNavView.PayBackAction = ^{
//        for (UIView *subViews in weakSelf.view.subviews) {
//            [subViews removeFromSuperview];
//        }
        CalculateLoanViewController *caculateLoanViewController = [[CalculateLoanViewController alloc] init];
        [weakSelf.view addSubview:caculateLoanViewController.view];
        [weakSelf addChildViewController:caculateLoanViewController];
        
    };
}


#pragma mark - Override
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.view endEditing:YES];
}

#pragma mark - Event Response


#pragma mark - Private
- (void)loadHouseLoanCalculateViewController{
    [self.MyNavView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view.mas_top);
        make.left.equalTo(self.view.mas_left);
        make.width.equalTo(self.view.mas_width);
        make.height.equalTo(@(59));
    }];
    
   [self.houseLoanCalculateView mas_makeConstraints:^(MASConstraintMaker *make) {
       make.top.equalTo(self.MyNavView.mas_bottom);
       make.left.equalTo(self.view.mas_left);
       make.width.equalTo(self.view.mas_width);
       make.bottom.equalTo(self.view.mas_bottom);
   }];
}


#pragma mark - Getter
- (DetailCaculateNavView *)MyNavView {
    if (!_MyNavView) {
        _MyNavView = [[DetailCaculateNavView alloc] init];
        _MyNavView.NavTitleString = @"房贷计算器";
        _MyNavView.BtnTitleString = @"还款详情";
        [self.view addSubview:_MyNavView];
    }
    return _MyNavView;
}

- (HouseLoanCalculateView *)houseLoanCalculateView{

    if (_houseLoanCalculateView == nil) {
        _houseLoanCalculateView = [HouseLoanCalculateView new];
        _houseLoanCalculateView.houseTotalPrice = _houseTotalPrice;
        [self.view addSubview:_houseLoanCalculateView];
    }
    return _houseLoanCalculateView;
}

@end
